package com.melodyframe.common.tools.bean;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * A tool for operate method of bean
 * 
 * @author ettear
 * 
 */
public class BeanMethodUtil {
	/**
	 * Get all methods which has the given annotation
	 * 
	 * @param beanClass
	 *            Class of given bean
	 * @param annotationClass
	 *            Class of given annotation
	 * @return The list of methods
	 */
	public static List<Method> getMethodsForAnnotation(Class<?> beanClass,
			Class<? extends Annotation> annotationClass) {
		List<Method> methods = new ArrayList<Method>();
		Method[] allMethods = beanClass.getMethods();
		for (Method method : allMethods) {
			if (method.isAnnotationPresent(annotationClass)) {
				methods.add(method);
			}
		}
		return methods;
	}
}
